<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="layout">
<head>
<title>优惠活动管理</title>
</head>
<body>
<div layout:fragment="content">
	<div class="row">
		<div class="table-toolbar col-md-12">
				<div class="btn-group pull-right">
					<a href="edit.html" onclick="beforeSkip(this)" th:href="@{/promotion/activities/add}" id="Link_add" class="btn green">添加活动<i class="fa fa-plus"></i></a>
				</div>	
				<div class="col-md-15 col-sm-13">
					<form class="form-inline" th:action="@{/promotion/activities/index}" th:object="${activitiesSearch}"  method="post" id="form_submit">
						
						<div class="form-group">
						<label class="sr-only" for="keyword">keyword</label>
							<input type="text" name="searchName" style="width:160px;" th:field="*{searchName}" placeholder="活动名"  id="searchName" class="form-control" />
						</div> 

						
						
						<div class="form-group" >
							<div class="col-md-4">
								<input id="searchBeginTime" name="searchBeginTime" style="width:120px;" th:field="*{searchBeginTime}" data-format="yyyy-MM-dd hh:mm:ss" placeholder="开始时间" class="form-control" type="text"></input>
							</div>
						</div>
						<div class="form-group"> 
							<div class="col-md-4">
								<input id="searchEndTime" name="searchEndTime" style="width:120px;" th:field="*{searchEndTime}" data-format="yyyy-MM-dd hh:mm:ss" placeholder="结束时间" class="form-control" type="text"></input>
							</div>
						</div>
						
						<div class="form-group"> 
							<div class="col-md-4">
								<select id="activitiesState" name="activitiesState" th:field="*{activitiesState}" class="form-control">
									<option value="0">全部</option>
									<option value="1">正在进行中</option>
									<option value="2">即将开始</option>
									<option value="3">已过期</option>
								</select>
							</div>
						</div>
						
						
						<button type="button" id="bt_search" name="bt_search" class="btn green" onclick="checkDate();">
							<i class="fa  fa-search"></i>
						</button>
					</form>
				</div>	 
		</div>
	</div>
	<div class="row">
		<div class="col-md-12">
			<div id = "div_activities_grid" th:include="promotion/activities/activities_table">
		
			</div>
		</div>
	</div>
</div>	
</body>
</html>
<script th:inline="javascript">
	/*<![CDATA[*/
		$("#searchBeginTime").click(function(){
			WdatePicker({startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd ',alwaysUseStartDate:true,readOnly:true});
		}).focus(function () {
            WdatePicker({startDate:'%y-%M-01 ',dateFmt:'yyyy-MM-dd ',alwaysUseStartDate:true,readOnly:true});
        });
		$("#searchEndTime").click(function(){
			WdatePicker({startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd ',alwaysUseStartDate:true,readOnly:true});
		}).focus(function () {
            WdatePicker({startDate:'%y-%M-01 ',dateFmt:'yyyy-MM-dd ',alwaysUseStartDate:true,readOnly:true});
        });
		
		KindEditor.ready(function(K) {
	        K.create('#textarea_content', {
	                uploadJson : '/upload',
	                allowFileManager : false
	     });
	});
		
		function beforeSkip(obj){
	        obj.href = obj.href + '?'+$('.paging_bootstrap ul .active a').attr('href').split('?')[1];
	    }	  
		  
		  function checkDate(){
			  var startTime=$("#searchBeginTime").val();  
			    var start=new Date(startTime.replace("-", "/").replace("-", "/"));  
			    var endTime=$("#searchEndTime").val();  
			    var end=new Date(endTime.replace("-", "/").replace("-", "/"));  
			    if(end<start){  
			        alert("开始时间要小于结束时间"); 
			        return  false;
			    }  
			  $("#form_submit").submit();
		  }
	       
	           
	/*]]>*/
</script>